import os
import sys

target = 'VISDKClient.lib'
ext = '.vcproj'


def FindDep(root = 'Z:\\NaviServices'):
    try:        
        for parent, dirNames, fileNames in os.walk(root):            
            for fileName in fileNames:
                if fileName[len(fileName)-len(ext):] == ext:
                    #print('parent: ' + parent)
                    #print('fileName: ' + fileName)
                    try:                        
                        with open(os.path.join(parent, fileName), 'r') as file:
                            try:
                                for line in file:
                                    # print('line: ' + line)
                                    if line.lower().find(target.lower()) != -1:
                                        print(os.path.join(parent, fileName))
                                        break
                            except UnicodeDecodeError:
                                print('The file is encoded in unknown format!' + os.path.join(parent, fileName))
                                pass
                    except IOError:
                        print('The file cannot open!' + os.path.join(parent, fileName))
                        pass
    except:
        print('Unknown exception!')
